Repository navigation
Conversation
Add a schema_releases table that only the schema owner writes, a release workflow in a protected environment, and a production build step that waits for its commit's schema release instead of migrating. The runner records a release after migrations and grants succeed, and records overtaken commits as superseded. Remove the build-time migration script.
Add guard triggers that refuse a change to an identity column of a grant, token family, access token, refresh token, client, tenant or service credential, a change of a set revocation or consumption time, and a delete or truncate of a grant, client, tenant, user, service credential or reviewer credential. Every guard holds for every role except the schema owner. Pin the search path of the schema owner's trigger and definer functions in the same migration. The grants script takes delete and the fixed-column update rights from the web app's role and revokes the trigger right on every table from every role but its owner. Narrow the grants test's every-right assertion to the tables the lock leaves alone.
Add exomem_cloud_issuance_log with a recording trigger on token families, access tokens, refresh tokens and service credentials. The recording function runs as the schema owner, so a credential insert fails when its record cannot be written. The log refuses every writer except the schema owner, and the migration writes one backfilled record for each existing credential row. A prune function, which only the web app's role may call, deletes records 90 days after their credential expires, in batches of 10000, and the reconcile job calls it. The grants script takes every right on the log from the web app's, gateway's and controller's roles, revokes execute on the new functions from PUBLIC, and gives the audit role read access. Add the log to the deletion receipt that the deletion-finish suite expects.
The download handler stores one row for each ticket before it redirects. The gateway's login lookup finds the ticket's row by token family, path digest and expiry inside the same statement, so a correctly signed ticket without its row finds no login. The web app's role can select, insert and delete ticket rows and cannot update them. The gateway role reads three columns. The reconcile job removes expired rows in bounded batches.
Two new suites attack the lock and the log as the web app's, the gateway's, the controller's and the audit role, in the narrow rights state that the grants script gives and in the wide state of an earlier script. Each attack asserts a refusal and an unchanged row. They also cover the guards alone, the older guards, the recording of every insert path, a renamed log table and the backfill of the migration. The grants suite gains the exact-rights checks, read from the catalog. Nine existing flow suites now run their production code through a pool that connects as the web app's role on the grants script's rights, so a flow that needs a withheld right fails in the test as it would in production. The code exchange, refresh, Home mint, service credential and download suites assert their issuance records. CI lists the two new suites. Tasks 2.1 to 5.8 are ticked.
The keys runbook now describes the protected migration job, the 15-minute build wait, the manual run with the operator's own copy of the credential, and the one build switch that skips the wait. The old build-time migration procedure and its pull of production variables are gone. The deployments runbook and the README say that a production build reads its schema release and never migrates, and that promotion, rollback and uploaded deployments do not check it. The operations runbook gains a section on what the lock refuses, the three emergency statements with what each suspends, the audit-role checks of the issuance log with their hourly overlap, the catalog checks, the size and retention reads, and the download ticket rows with their deploy and rollback order. Tasks 6.1 to 6.3 are ticked.
…n foreign schemas A web-role insert into the download ticket table could name another tenant's token family with a grant of its own. The gateway matches a ticket on the family, the path digest and the expiry, so it admitted the ticket, and the issuance record named the inserting role's tenant and user. - Refuse a ticket row whose grant is not its token family's grant, or whose family does not exist, for every role (new definer function with a pinned path). The recording function now reads the grant through the family for tickets, as it does for refresh tokens. - Raise, and so roll back the first migration, when a schema on the migration path belongs to a role other than the schema owner, the bootstrap superuser or pg_database_owner. The error names each schema and its owner. The earlier notice left such schemas out of the pin, and the pinned functions then failed at their next call. - Refuse a change to cell_id or tenant_id on exomem_cloud_cells, and a delete or truncate, for every role except the schema owner. No code changes those columns or deletes a cell row as another role. - Add the schema release suite to the CI PostgreSQL list. - Update the design, the gateway and OAuth specs, the task list and the runbook, and name the gateway use log as a later step for limit 9.
…PostgreSQL suites serially - Remove the download ticket grant guard and the ticket row's grant column. The gateway already requires the token family to carry the grant that the signed ticket names, so a role that inserts a row can name only a family with its real grant. That is issuance, which the log records. The handler stops writing the grant, and the recording function reads the grant, tenant and user through the token family. - Give a service credential's record an end. A service credential has no expiry, so its record was never pruned. The recording function now sets the record's end to the database clock when the credential is revoked or its row is deleted, and the prune deletes it 90 days later. The clock is used, not revoked_at, which the web role writes and could set in the past to bring the prune forward. A partial index finds the record. - Share one login-role password between the suites that create the same cluster-wide roles, and run the PostgreSQL steps in test.yml with --test-concurrency=1, because roles and grants belong to the cluster. - State the retention plainly in the proposal and the design: 90 days after expiry or end, up to 365 plus 90 days for a token family, and past account deletion for that window. Add cells to the identity lock bullet, match the release plan's 100 first-parent ancestors, and mark the size estimate as a lower bound.
…e rollout text The claim now names the credentials the gateway admits, and Limit 2 states what the web app's role can and cannot do with export, import and deletion grants. The column-rights requirement names the five column-locked tables. A failed migration job also needs a redeploy of a production build that already failed. Task 5.8 says where the run's outputs are kept, and task 7.4 gives the audit role's creation statement.
… the unscheduled checks The two OAuth requirements now name the table rights they hold against and point to the limit that lists what can still change the lock. Retention states the session policy's expiry bounds and that the database bounds no expiry. The limits add reviewer credentials, which the web app's role can still revive, and the manual running of the log checks. The Home mint proof note keeps its outputs in a private record.
…uance log whatever the other lanes do A token family's record now ends at the database clock when the family is revoked or its row is deleted, an account's deletion included, like a service credential's record. Both kinds keep their record 90 days from then. A partial index on the family records finds the record, and the backfill ends the record of a family that is already revoked. The reconcile route now runs the issuance prune as a lane beside the others, so a failure in another lane no longer skips it. A prune part that fails fails the response, and the response carries the counts or null for a failed part in both the success and the failure case. The proposal, design, spec, tasks and runbook state the retention bound after an account's deletion, from the session policy's refresh idle window.
…tate what D12 check 1 reads A service credential belongs to the tenant, not to one cell. Nothing revoked it when the tenant's cell was deleted, so its issuance record kept no end and the prune never deleted it. A live credential would also have served the tenant's next cell after re-admission. The statement that revokes a deleted cell's consent now also revokes the tenant's unrevoked service credentials. It sets the revocation time from the database clock and leaves the revoking principal empty. The existing trigger ends each credential's record. The unpaid-invite expiry, the lifecycle reconcile and the account deletion all run the statement, and the deletion finish repeats it, so a second run changes nothing. The web app's role already holds update on that column, so no grant changes. A PostgreSQL test runs the account deletion as that role and checks that another tenant's credential and its record stay open. Text: the proposal, D6, limit 8, the service credentials spec and the runbook now give the post-deletion bound for service credentials. D12, limit 13, the OAuth spec and the runbook now say that check 1 reads the five credential tables in full, is run on demand, and needs an index on created_at or a different query before anything schedules it. D7 and task 5.8 now say that the pgbench script and the 10,000-tenant generator are kept with the private record of the run.
…fill only records the prune keeps The previous commit revoked a tenant's service credentials from the statement that revokes a deleted cell's consent. That left the release that serves during a build, and an instant rollback, with no revocation. This commit reverts that statement, so the PR again changes no existing SQL of those flows, and moves the rule into migration 0102. An AFTER UPDATE row trigger on the cells table fires when a cell's desired state becomes deleted, and an AFTER DELETE trigger fires when a row that is not yet deleted goes. Both set the revocation time from the database clock on the tenant's unrevoked service credentials and leave the revoking principal empty. The existing trigger ends each credential's record. The function runs with its caller's rights and pins its search path: only the web app's role sets a cell's desired state, and it already holds update on that column, so no grant changes. No check for another live cell is needed, because one index allows a single cell that is not deleted for each tenant. The second migration now locks cells first, the order in which the flows write them. The migration also revokes once, at its own time, the unrevoked service credentials of every tenant that has no cell other than deleted ones, so the credentials of accounts that an earlier release deleted end too. No record stays open after that. The backfill now writes a record only for a row whose record the prune would keep: its end is empty or at most 90 days old. A token that expired earlier gets none, which shortens the lock on a large old table. Task 7.4 gives the operator the count query with the same predicate. The runbook's first range run starts at the log's first record, so check 1 does not list a skipped row. PostgreSQL tests, in both rights states: the web app's role sets a cell deleted and the tenant's credentials and records end at the database clock; another tenant's stay live; a stop changes nothing; a second update changes nothing; a delete by the schema owner of a live cell row ends them, and a delete of an old deleted row beside a live cell does not. The migration test ends a deleted tenant's live credential, keeps a live tenant's, and writes no record for a token that expired 100 days earlier. Text: the proposal, D5, D6, D12, limit 8, Risks, Open Question 1, tasks 3.1, 3.4, 5.4 and 7.4, both delta specs and the runbook.
…that cell A service credential that commits just after a cell's deletion trigger ran stays unrevoked and serves the tenant's next cell after re-admission. A BEFORE INSERT trigger on exomem_cloud_service_credentials now reads the tenant's cell that is not deleted with FOR SHARE and refuses the insert (SQLSTATE 23503, constraint exomem_cloud_service_credentials_live_cell) when none exists. A deletion that starts after the insert waits for the insert to commit, and its trigger then revokes the new credential. An insert that waits for a deletion is refused once the deletion commits. The trigger function runs with its caller's rights and pins its search path. The migration and the grants script revoke its execute right. The service credential request answers the refusal as SERVICE_CREDENTIAL_TENANT_INELIGIBLE (409). The lifecycle sweep locks a cell before its tenant and a request locks the tenant first, so the two can deadlock; D5 records that and PostgreSQL fails one of them. Tests run as the web app's role in both rights states, on two connections with a statement timeout: refusal for a deleted-only tenant, a deletion that waits for an open insert, and an insert that waits for an open deletion. The seed world now has a live cell, as a credential needs one.
The lifecycle sweep locks a cell before its tenant, and a service credential request locks the tenant first, so the two can deadlock and PostgreSQL then fails one of them. The request now maps SQLSTATE 40P01 to 503 SERVICE_CREDENTIAL_RETRY, retryable, with a Retry-After of 3 seconds, instead of a bare 500. The transaction rolled back whole, so the operator sends the request again. The route does not retry. The operator error response now sends Retry-After whenever an error names a delay. A serialization failure (40001) cannot reach the request: its transactions run at READ COMMITTED.
The runbook's range query named the record that the previous run stopped at. The prune can delete that record, and the read then started at the beginning of the log. It now anchors on the nearest record at or below that point, and starts at the oldest record when none survives, which is the unread range. An empty log gives an empty range. Check 3 now says what a hit means: the web app's role inserted a grant for someone other than the tenant's owner. Task 5.8 now names the commit that its run measured and stays open. The triggers that end token family records, the cell deletion triggers and the service credential insert trigger came after that run, so a rerun is owed. D7 no longer says that the run's script and generator are kept.
The suite stored each ticket row and ran the gateway's lookup as a superuser, which holds every right. The link handler now runs as the web app's role and the gateway's lookup as its own narrower role, on the rights of the grants script. The superuser pool only seeds and asserts. A removed column right on the gateway or a removed insert right on the web app now fails the suite.
The cost proof ran again on commit e8a7c3d, which holds every trigger of the change, and met each part of its pass condition. Task 5.8 names that commit and is ticked. D7 and the task say that the proof's script, generator and outputs are kept with the private record, so a later change to the triggers or the guards reruns it with the same instrument.
The production build of the commit before this change can still be in flight at the merge. It waits for the migration job's lock, then applies the earlier grants script, which gives the web app's role select, insert, update and delete on every table, the log included. A redeploy of an earlier commit does the same. A dry run applies no grants, so the rollout step that ended with a dry run did not undo it. Task 7.7 now ends with a run of the migration job that is not a dry run, and checks the role's rights. The runbook gains a catalog check that lists each right of the web app's role beyond what the grants script gives it: any right on the log or its sequence, a write on schema_releases, an update of a ticket row, a delete on a table whose rows the role never deletes, and an update of a column outside a locked table's changeable list. Task 7.6 runs it, the design names the in-flight build as a way the old grants return, and the spec's list of checks and the count of catalog checks follow. The identity requirement of the OAuth spec now limits the one-way revocation and consumption rule to grants, token families, access tokens and refresh tokens, and points to design limits 5 and 12 for clients and reviewer credentials.
The runbook's check of the web app's rights repeated the changeable column lists of the grants script. Nothing kept the two in step, so a later grants change would have made the check list a legitimate right and sent the operator after a grant that does not exist. For the five column-locked tables and for clients and tenants, the query now lists only a table-wide update, which the grants script never gives. It counts a right held through PUBLIC or a membership, and ignores a single column grant, which the guard refuses to honour for a locked column. The rows for the log and its sequence, schema_releases, ticket rows and the deletes stay as they were. The runbook says that a column grant is not listed, and its recovery steps name the causes of a surviving row in order: a build of an earlier commit that still runs, then a right through PUBLIC or a membership. D12 and the spec's scenario say "table-wide" for the locked tables.
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 42547429 | Triggered | Generic Password | 1da34cb | src/lib/exomem-hosted/tests/flow-pool.ts | View secret |
| 42549531 | Triggered | Generic Password | 1ffc868 | src/lib/exomem-hosted/tests/test-role-password.ts | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Quality report
Gate: passedNothing found by knip. Proof weightProduct +1548 lines against proof +3899 lines (tooling, specs, tests, fixtures). Measures on added lines
New duplicate code, exact token clones (jscpd) Test runtimeThis run against the median of the last 5 successful
Every table: this run's summary. |
…e statement The schema release job could lose a newer push's release when two runs overlapped in the concurrency group. The runbook's log reads could list a credential whose record the prune had rightly deleted, and could read the whole log on a first run. The two end-time updates of the second migration used the transaction's start time. Schema release - Every run checks out main, installs, then reads the tip of origin/main again with scripts/schema-release-plan.sh. It applies that tip only when its checkout equals the tip, and records that commit. When main moved during the install, the run ends green with a notice: the push that moved main started its own run. The push trigger has no path filter, and a test holds that. - A dry run takes its own concurrency group, takes no advisory lock and creates no schema_migrations table: an absent table reads as an empty set. - --record-superseded and recordSupersededOnly are removed. Every run now releases the tip, so no run has superseded commits left to record. - schema_releases gets a partial index on released rows, newest first, so the wait script's poll reads one index entry and no longer sorts the table. - A test applies and records the tip of a disposable two-commit remote, and applies nothing once main has moved on. Record ends - A service credential's record and a token family's record end at statement_timestamp(), as does a cell's revoked_at, so a transaction that stays open after the revoking statement no longer lengthens the record. Runbook reads - Check 1 lists only credentials that must still have a record: created in the last 90 days and after the second migration was applied. The audit role cannot read expiry columns or schema_migrations, so the operator reads the install time once and passes it to every run. A live service credential older than 90 days is not checked. - Each run reads at most one page of identifiers, 100,000 by default and the operator's to change. The operator repeats the run from its stop until it reaches the newest identifier. Checks 2 and 3 and the log side of check 1 stay primary-key index ranges, including the first run. - The dry listing of the release steps takes no lock. Specification and design - The tasks, D5, D9, D12 and the two specs follow the above. Task 7.4 and D5 count the rows that each backfill read scans, which are the full source tables, and use that count for the lock window and the go/no-go. Two symbols of the lock fixture are no longer exported.
… at one page A run of the runbook's range checks set its stop to its start plus one page. The migration's backfill is one transaction, so all its records share one recorded_at and no record is an hour older. With a backfill of one page or more, the start went back to the first record, the stop equalled the previous stop, and the run never advanced. Each run now counts from the previous stop: - The look-back to a record one hour older goes back at most one page. - The stop is the lesser of the newest identifier and the previous stop plus one page, so it rises on every run while the previous stop is below the newest identifier. A run reads at most two pages. - The first check's lo_time is the time of the first record at or after the start, because the record at the start can be absent. Its window keeps the install clamp and hi_time. A pass's lo_time is at or before the previous pass's hi_time, or it is the install time, before which the check lists nothing. - The runbook says that the backfill holds no late commit, that a finding inside the overlap shows in two passes, and that the page must stay above one hour of writes, or the cap on the look-back can miss a late commit. D12, the spec scenario for a range check and task 7.6 follow.
The recorder gives a record its end at the insert when a service credential or a token family is inserted already revoked. Before, a service credential kept an open record that the prune never selects, and a family kept its future expiry. A PostgreSQL test covers each kind through the web app's role. The rights check now lists truncate and references on the log, at table level and on a column. The trigger right keeps its own check. The range reads change in two ways: - The credential window is exclusive at both ends. A token family and its first access token share one creation time, and the family's record can sit one identifier below the start of a pass. - The look-back has no cap in records. It walks to the nearest record that is an hour older and stops at the end of the backfill, which the operator reads once with the install time. A cap left a hole whenever an hour held more than a page of records. A pass now reads one hour of records and at most one page, so the page no longer affects what a pass finds. The no-build deploy procedure now requires a schema release for the candidate's commit or a newer one before it serves, and keeps the compatibility check for a candidate older than the newest release. D12, the range scenario of the OAuth spec and task 7.6 follow the runbook.
|
Automated review: REQUEST_CHANGES Do not ship this patch. The issuance audit does a full scan on every page, and the migration instructions can send a local command to the wrong database. Risk lens: yes
Reviewed patch GitHub reported no CI or Quality result for the reviewed head. Both passed on Weight from the reviewed diff: +1,521/−105 product, +3,801/−209 proof, +549/−14 docs. The role, migration, and existing-flow cases account for the heavier proof. Blocking: 2 |
|
Automated review: APPROVE The correction closes the fixed-snapshot deletion race, makes the audit cutoff independent of the caller's time zone, and gives ticket issuance a bounded cleanup path. The current patch is ready for exact-head checks. Representative load and rollout evidence remain open. Weight 1,653 changed product lines and 4,686 changed proof and documentation lines. The runbook still describes a one-day limit on stored rows. One day limits authorization. Expired rows can remain until cleanup. |
|
Automated review: APPROVE Approved the final patch. The runbook gives the one-day limit for download authorization and says that expired rows stay until cleanup. The migration changes comments only. Its executable SQL matches the previous review. Weight 1,653 changed product lines and 4,687 changed proof and documentation lines. Exact-head CI, representative-load evidence, and rollout approval remain separate. |
|
Automated review: APPROVE Review note: The two-file correction at Against Risk lens: yes GitHub reported no checks for this head. Code approval is separate from CI, task 5.8’s projected-load proof, and operator rollout approval. Blocking: 0 |
Locks the identity rows that determine which tenant a Cloud credential reaches. The database records each credential in an issuance log that the web app's role cannot edit.
main. Vercel reads that release on production builds, and the runbook requires a release check for no-build deployments.Why. The web app's database role needs to issue credentials. Database grants and row guards restrict what it can change after issue.
Proof. The PostgreSQL suites in CI exercise issuance, identity guards, and grants. The audit queries found all seeded gaps across small pages in disposable PostgreSQL.
Risk and undo. Keep this PR in draft until the migration environment and database checks pass. Merging starts the production migrations. If the migration job fails, fix the cause before retrying and redeploy any failed build. The runbook gives the recovery order.
Change:
openspec/changes/lock-cloud-identity-rows-and-record-issuance/.User note: none